package edu.hubu.work01.Service.impl;

import edu.hubu.work01.entity.Cow;
import edu.hubu.work01.mapper.CowMapper;
import edu.hubu.work01.Service.CowService;
import edu.hubu.work01.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CowServiceImpl implements CowService {
    @Autowired
    private CowMapper cowMapper;
    public ResultVO addCow(Cow cow){
        int i = cowMapper.addCow(cow);
        if (i > 0) {
            return new ResultVO(200, "入栏成功！", null);
        } else {
            return new ResultVO(500, "入栏失败！", null);
        }
    };
    public ResultVO removeCow(int cowId){
        int i = cowMapper.removeCow(cowId);
        if (i > 0) {
            return new ResultVO(200, "出栏成功！", null);
        } else {
            return new ResultVO(500, "出栏失败！", null);
        }
    };

    public ResultVO selectCow(int cshdId){
        List<Cow> cow = cowMapper.selectCow(cshdId);
        if (cow != null) {
            return new ResultVO(200, "查询到", cow);
        } else {
            return new ResultVO(500, "没有", cow);
        }
    };
    public ResultVO listCow(){
        List<Cow> cows = cowMapper.listCow();
        if (cows != null) {
            return new ResultVO(200, "查询到", cows);
        } else {
            return new ResultVO(500, "没有", cows);
        }
    }
    public ResultVO markCow(int cowId,String remark){
        int i = cowMapper.updateRemark(cowId,remark);
        if (i>0) {
            return new ResultVO(200, "查询到", null);
        } else {
            return new ResultVO(500, "没有", null);
        }
    }
}
